package com.kkb.service.file.impl;

import com.kkb.bean.TagsTable;
import com.kkb.dao.TagsTableMapper;
import com.kkb.service.file.TagsTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @Author 何世鹏
 * @Date 2021/4/12 10:56
 */
@Service
public class TagsTableServiceImpl implements TagsTableService {

    @Autowired
    private TagsTableMapper tagsTableMapper;

    /**
     * 添加标签
     *
     * @param req  请求
     * @param resp 响应
     * @return 添加是否成功
     */
    @Override
    public Boolean addTags(HttpServletRequest req, HttpServletResponse resp, TagsTable tagsTable) {
        //HttpSession session = req.getSession();
        Integer id = 1;//(Integer) session.getAttribute("id");
        if (id != null) {
            //添加标签
            List<TagsTable> select = tagsTableMapper.select(tagsTable);
            if (select == null) {
                int insert = tagsTableMapper.insert(tagsTable);
                return insert>0;
            }else {
                return true;
            }
        }
        return false;
    }
}
